import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class SwiperPage extends StatefulWidget {
  @override
  SwiperPageState createState() {
    return SwiperPageState();
  }
}

class SwiperPageState extends State<SwiperPage> {



  @override
  Widget build(BuildContext context) {
    return Scaffold(

      body: Container(
          width: MediaQuery.of(context).size.width,
          height: 200,
          child: Swiper(

            itemBuilder: _swiperBuilder,
            itemCount: 4,
            pagination: new SwiperPagination(
                builder: DotSwiperPaginationBuilder(
                  color: Colors.white,
                  activeColor: Colors.orangeAccent,
                )),
            control: new SwiperControl(),
            scrollDirection: Axis.horizontal,
            autoplay: true,
            onTap: (index) => print('点击了第$index个'),
          )),
    );
  }

  Widget _swiperBuilder(BuildContext context, int index) {

    index+=1;
      return  Container(
          child: Image.network(
            "http://106.12.180.103/smartDemo/images/banner"+ index.toString()+".png",
            fit: BoxFit.fill,
          ),
        );

  }
}